Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

204
Visualizações
trying to create a ipfs img uploader getting this error : "Uncaught TypeError: Cannot read properties of undefined (reading '0')"

this is my app.js code going through a ipfs image uploader code along video by dapp university . facing this issue im new to blockchain i think there is a problem with this line of code const file = event.target.files[0]


  captureFile(event) {
    event.preventDefault()
    const file = event.target.files[0]
    const reader = new window.FileReader()
    reader.readAsArrayBuffer(file)
    reader.onloadend = () => {
      this.setState({ buffer: Buffer(reader.result) })
      console.log('buffer', this.state.buffer)
    }
  }

onSubmit(event){
  event.preventDefault()
  console.log("on submit......")
  ipfs.default.files.add(this.state.buffer,(err, result)=>{
    if(err){
      console.err("belp")
      return
    }
    
     this.setState({ipfshash:result[0].hash})
     console.log("ipfshash",this.state.ipfshash)
  }) //api installed accessed in header
}
  render() {
    if (!this.state.web3) {
      return <div>Loading Web3, accounts, and contract...</div>;
    }
    return (
      <div className="App">
        
        <h1>IPFS UPLOADER DAPP!</h1>
        <p>THIS IMAGE IS STORED IN IPFS.</p>
        <img src ="" alt=""/>
        <h2>upload image:</h2>
       <form onSubmit={this.onSubmit} >
<input type='file' onChange={this.captureFile}/>
<input type='submit'/>
</form>
        {/* <p>
          Try changing the value stored on <strong>line 42</strong> of App.js.
        </p>
        <div>The stored value is: {this.state.storageValue}</div> */}
      </div>
    );
  }
}

export default App;
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda